class Solution {
public:
    int maxProfit(vector<int>& prices) 
    {
        int sum = 0, maxprofit = 0;
        int n = prices.size();
        
        for(int i = 0; i < n - 1; i++)
        {
            for(int j = i + 1; j < n; j++)
            {

                if(prices[j] > prices[i])
                {
                    sum = prices[j] - prices[i];
                    maxprofit = max(sum, maxprofit);
                }
                
                else sum = 0;
                
            }      
        }

        return maxprofit;
    }
};

//简单双重循环